import Cookies from 'js-cookie'
import { Base64 } from 'js-base64';

const TokenKey = 'pacargle'

export function getToken() {
  
  // let sub=eval('(' + Base64.decode(Cookies.get(TokenKey).split(".")[1]) + ')');
  // console.log("5555555555",sub.roleCode)
  return Cookies.get(TokenKey);
  

}

export function setToken(token) {
  Cookies.set(TokenKey, token);
  let sub=eval('(' + Base64.decode(token.split(".")[1]) + ')');
  Cookies.set("NICKNAME",sub.nickName);
  Cookies.set("ROLEID",sub.roleId);
  Cookies.set("MANAGERID",sub.mangerId);
  Cookies.set("ROLECODE",sub.roleCode);
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

export function getNickName(){
  return Cookies.get("NICKNAME");
}

export function getRoleId(){
  return Cookies.get("ROLEID");
}

export function getManagerId(){
  return Cookies.get("MANAGERID");
}

export function getRoleCode(){
  return Cookies.get("ROLECODE");
}

export function getTestUserName(){
  return 'testuser'
}